//
//  CYReleaseTypeVC.m
//  CreditAddressBook
//
//  Created by LE on 16/1/6.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "CYReleaseTypeVC.h"
#import "CYLoginHttpTool.h"
#import "CYReleaseVC.h"
#import "CYPersonalDetailsVController.h"
#import "CYJumpsTool.h"
#import "CYCommonReleaseTVC.h"
#import "CYHelpViewController.h"
#import "LEBarButtonItem.h"
#import "CYPersonReleaseVC.h"
#import "CYDiscoveryHttpTool.h"
#import "CYNEWFabuVC.h"

@interface CYReleaseTypeVC ()

@property (weak, nonatomic) IBOutlet UIButton *commonPubBtn;
@property (weak, nonatomic) IBOutlet UIButton *authorityPubBtn;
@property (weak, nonatomic) IBOutlet UIButton *helpBtn;
@end

@implementation CYReleaseTypeVC

- (void)viewDidLoad {
     
    [super viewDidLoad];
    //添加更多按钮
     LEBarButtonItem *more = [[LEBarButtonItem alloc] initWithImagelong:[UIImage imageNamed:@"icon_wyfb(1)"] andSelImage:nil target:self action:@selector(moreBtn)];
     self.navigationItem.rightBarButtonItem = more;

}
- (void)helpbtn{
    
    
}
- (void)moreBtn{
    CYUser *user = [CYLoginHttpTool userData].user;
    if (user) {
        //借用余额验证是否处于登录状态
        [CYDiscoveryHttpTool getUserAccountBalanceWithParam:@{@"userId": user.userId, @"token": user.token} success:^(CYUserAccount *userAccount) {
           CYPersonReleaseVC *personvc = [[CYPersonReleaseVC alloc]init];
            [self.navigationController pushViewController:personvc animated:YES];
        } failure:^(NSString *message, BOOL isLogin) {
            if (!isLogin) {
            [CYJumpsTool jumpToLogin:self];
            }
        }];
    }
}


- (IBAction)commonPubBtn:(UIButton *)sender {
    CYUser *user = [CYLoginHttpTool userData].user;
    if (user) {
        CYCommonReleaseTVC *release = [CYCommonReleaseTVC le_loadFromStoryBoard:[CYJumpsTool mainSB]];
        [self.navigationController pushViewController:release animated:YES];
    }else{
        
        [CYJumpsTool jumpToLogin:self];
    }
}
- (IBAction)authorityPubBtn:(UIButton *)sender {
    [self releaseClick];
}
- (IBAction)helpBtn:(UIButton *)sender {
    CYHelpViewController *helpvc = [[CYHelpViewController alloc]init];
    [self.navigationController pushViewController:helpvc animated:YES];
    
}
#pragma mark - 违约发布
- (void)releaseClick {
    CYUser *user = [CYLoginHttpTool userData].user;
    if (user) {
        if (CYStringEqualTo(user.certificateExamineStatusText, @"审核通过")) {
            CYReleaseVC *release = [CYReleaseVC le_loadFromStoryBoard:[CYJumpsTool mainSB]];
            
            [self.navigationController pushViewController:release animated:YES];
        } else {
            CYAlertView(@"您无权进行该操作，请先进行审核");
            CYPersonalDetailsVController *personDetail = [self.storyboard instantiateViewControllerWithIdentifier:@"CYPersonalDetailsVController"];
            [self.navigationController pushViewController:personDetail animated:YES];
        }
    } else {
        [CYJumpsTool jumpToLogin:self];
    }
}
@end
